#This module contains the spatial and the temporal parameters for the 1D vectorized Richards Equation
import numpy as np 
pars_MZs = np.loadtxt('./core_rl_mz2_40/Parameters_LSTM.txt')
#Wheat was planted in this quadrant and the rooting depth was found to be between 0.5 - 1.0 m
def spatialVariables_1D():
    totalDepth      = 0.32   # in meters ('m')
    axialNodes      = 17
    axialDistance   = totalDepth/(axialNodes-1)
    totalNodes      = axialNodes
    totalStates     = totalNodes
    dimenProcNoise  = totalStates
    numOfActuators  = 1
    interPoints     = 500
    return totalDepth, axialNodes, axialDistance, totalNodes, numOfActuators, interPoints

def spatialVariables_1D_act():
    totalDepth      = 1.0    # in meters ('m')
    axialNodes      = 31
    totalNodes      = axialNodes
    totalStates     = totalNodes
    dimenProcNoise  = totalStates
    return totalDepth, axialNodes, totalNodes


def temporalVariable():
    samplingTime   = 1*4*6*60*60
    samplingTimeInternal = 1*4*6*60*60
    simulationTime = 1*6*4*60*60
    internalTimeSteps = int(samplingTime/samplingTimeInternal)
    totTimeSteps   = int(simulationTime/samplingTime)
    return samplingTime, samplingTimeInternal, internalTimeSteps, totTimeSteps    

def temporal_discretization(_points):
    samplingTime   = 1*4*6*60*60
    samplingTimeInternal = (samplingTime/_points)
    simulationTime = 1*6*4*60*60
    internalTimeSteps = _points
    totalTimeSteps   = int(simulationTime/samplingTimeInternal)
    totalTimeSteps_daily = int(samplingTime/samplingTimeInternal)
    return samplingTime, samplingTimeInternal, internalTimeSteps, totalTimeSteps_daily, totalTimeSteps  

def generatingCoordinates_1D(axialNodes):
    #Coordinates are used to identify each node present in the mesh
    coordinates=[]
    for k in range(axialNodes):
        y=[0,0,k]
        coordinates.append(y)            
    return coordinates

def pars_mz2(): # Loamy soil
    soilPars={}
    soilPars['thetaR'] = 0.078
    soilPars['thetaS'] = 0.43
    soilPars['alpha']  = round(pars_MZs[1,2], 1)
    soilPars['n']      = 1.56
    soilPars['m']      = 1-1/round(soilPars['n'], 2)
    soilPars['Ks']     = (round(pars_MZs[1,0], 2))/86400
    soilPars['neta']   = 0.5
    soilPars['Ss']     = 0.00001
    return soilPars
